#! /usr/bin/env python

# The Python doesn't have enums.
# This hack provides enums.
# Compatible with Python 2 and 3.

class Enum(object):
	def __init__(self, *autoval, **manualval):
		self.__dict__.update(zip(autoval, range(len(autoval))), **manualval)
	class EnumError(TypeError): pass
	def __setattr__(self, name, value):
		if name in self.__dict__:
			raise self.EnumError("Can't rebind enum item (%s)" % name)
		self.__dict__[name] = value
	def items(self):
		return self.__dict__
	def names(self):
		return self.__dict__.keys()
	def values(self):
		return self.__dict__.values()
		